#!/bin/sh

#for debugging:
set -x

#edit the com.extensis.server.web.admin.launchd.plist file so it can find the launch-jetty.sh script
#first, make a copy of the plist file or we'll ding up the original
sudo cp -f "$1/Contents/Resources/com.extensis.server.web.admin.launchd.plist" "/Library/LaunchDaemons/com.extensis.server.web.admin.launchd.plist"
sudo sed -i '' -e "s|%TARGETDIR%|$2|" "/Library/LaunchDaemons/com.extensis.server.web.admin.launchd.plist"

#we need to set the permissions
sudo chmod 644 /Library/LaunchDaemons/com.extensis.server.web.admin.launchd.plist > /dev/null
sudo chown root:wheel /Library/LaunchDaemons/com.extensis.server.web.admin.launchd.plist > /dev/null

exit 0
